import javax.swing.JLabel;
class BubbleSort<T extends Comparable<T>> extends SortAlgorithm<T> { 
    BubbleSort(JLabel listLabel, JLabel timeLabel, JLabel averageTimeLabel, JLabel statusLabel) { 
        super(listLabel, timeLabel, averageTimeLabel, statusLabel); 
    }
    //Outer loop: i-- from N-1 to 1
    //Loop: j++ from 0 to i
    //Swap everytime a[j] > a[j+1]
    //That will "bubble" up biggest number to position i
    @Override
    protected void sort() {
        int N = m_list.size();
        for (int i = N - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (less(j+1, j)) swapElements(j, j+1);
            }
        }
    }
}